package cn.com.cnxfs.relaxchat.controller;

import cn.com.cnxfs.relaxchat.entity.Login;
import cn.com.cnxfs.relaxchat.entity.Swap;
import cn.com.cnxfs.relaxchat.service.ILoginService;
import cn.com.cnxfs.relaxchat.service.ISwapService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping(value = "/swap")
public class SwapController {
    @Autowired
    private ISwapService iSwapService;

    @RequestMapping(value="/receive",method = RequestMethod.POST)
    private List<Swap> receive(@RequestParam int friend){
        return iSwapService.receive(friend);
    }

    @RequestMapping(value="/add",method = RequestMethod.POST)
    private void add(@RequestBody Swap swap){
        iSwapService.add(swap.getUid(),swap.getFriend(),swap.getVar());
    }

    @RequestMapping(value="/del",method = RequestMethod.POST)
    private void del(@RequestBody Swap swap){
        iSwapService.del(swap.getVar());
    }
}
